package com.xiangyang.controller;

import com.xiangyang.entity.dto.Result;
import com.xiangyang.entity.vo.UserPermissionVO;
import com.xiangyang.service.IPermissionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/permissions")
@CrossOrigin
public class PermissionsController {
    @Autowired
    private IPermissionsService permissionsService;

    @GetMapping("/getPermissionsList")
    public Result<Object> getPermissionsList() {
        return permissionsService.getPermissionsList();
    }

    @PostMapping("/updatePermissions")
    @PreAuthorize("hasAnyAuthority('sys:adim')")
    public Result updatePermissions(@RequestBody UserPermissionVO upvo) {
        return permissionsService.updatePermissions(upvo);
    }

}
